
package gui.panels;

import gui.MainFrame;
import gui.listeners.GuiActionEvent;
import gui.listeners.GuiActionEventData;
import gui.listeners.GuiActionEventType;
import gui.model.DrinkModel;
import gui.panels.components.MmiButton;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

/**
 *
 * @author JtR
 */
public class SelectDrinkPanel extends GuiPanel {
    private MmiButton coffeButton, teaButton, favoriteButton;
    private JLabel title;
    
    public SelectDrinkPanel(MainFrame parent) {
        super(parent, BackgroundType.BOTH);
    }
    
    @Override
    protected void initComponents() {
        coffeButton = new MmiButton("res/kaffeepause/kaffeetasse.png", 477);
        coffeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.CHOSE_COFFEE));
            }
        });
        constraints.insets = new Insets(194, 40, 0, 0);
        add(coffeButton, constraints);
        
        teaButton = new MmiButton("res/teetime/teeglas.png", 300);
        teaButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.CHOSE_TEA));
            }
        });
        constraints.insets = new Insets(85, 610, 0, 0);
        add(teaButton, constraints);
        
        favoriteButton = new MmiButton("res/star.png", 150);
        favoriteButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.SHOW_FAVORITES));
            }
        });
        constraints.anchor = GridBagConstraints.NORTHEAST;
        constraints.insets = new Insets(0, 0, 0, 0);
        add(favoriteButton, constraints);
    }

    @Override
    public String getDescription() {
        return "Bitte wählen Sie Ihr Getränk";
    }

    @Override
    public void updateFields() {
    }

    @Override
    public boolean getPreviousButtonEnabled() {
        return false;
    }

    @Override
    public boolean getNextButtonEnabled() {
        return DrinkModel.getInstance().getDrink() != null;
    }

    @Override
    public String getName() {
        return "DRINKS_NAME";
    }

    @Override
    public GuiPanel getNextPanel() {
        switch(DrinkModel.getInstance().getDrink()) {
            case COFFEE:
                return parent.selectCoffeePanel;
            case TEA:
                return parent.selectTeaPanel;
            default:
                throw new RuntimeException();
        }
    }

    @Override
    public GuiPanel getPreviousPanel() {
        return null;
    }
}
